package upc.edu.pe.dominio;

import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;



@RooJavaBean
@RooToString
@RooDbManaged(automaticallyDelete = true)
@RooEntity(versionField = "", table = "cuotas", schema = "condominios", finders = { "findCuotasesByCodVivienda" })
public class Cuotas {

    @SuppressWarnings("unchecked")
    public static List<Cuotas> buscaCuotas(Integer vivienda) {
        EntityManager em = Cuotas.entityManager();
        Query q= em.createQuery("SELECT a  FROM Cuotas a inner join fetch a.codVivienda v where v.numeroVivienda=:vivi and a.codEstadocuotas=1" , Cuotas.class);
        q.setParameter("vivi", vivienda);        
        
        return q.getResultList();
    }    
	
    @SuppressWarnings("unchecked")
    public static List<Cuotas> buscaMorosos() {
        EntityManager em = Cuotas.entityManager();
        Query q= em.createQuery("SELECT a  FROM Cuotas a where a.codEstadocuotas=1" , Cuotas.class);
        //q.setParameter("vivi", vivienda);
        return q.getResultList();
    }     
}
